package com.boang.file;

import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;

/*
@author:22567
@date:2024/12/13 9:23
*/
public class FileDemo {
    public static void main(String[] args) throws IOException {

//        createFile();

//        deleteFile();

//        check();

    }

    private static void check() {
        File file = new File("c:\\Users\\22567\\Desktop\\java作业");
        File[] files = file.listFiles();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        for (File f : files) {
            System.out.println(f.getName() + simpleDateFormat.format(new Date(f.lastModified())));
        }
    }

    private static void deleteFile() {
        File file = new File("c:\\Users\\22567\\Desktop\\file\\a.txt");
        file.delete();
        File dir = new File("c:\\Users\\22567\\Desktop\\file");
        dir.delete();
    }

    private static void createFile() throws IOException {
        File dir = new File("c:\\Users\\22567\\Desktop\\file");
        dir.mkdir();
        File file = new File("c:\\Users\\22567\\Desktop\\file\\a.txt");
        file.createNewFile();
    }
}
